﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeTime.Sample {
	class Program {
		static void Main(string[] args) {
			CodeTimer.InitializeBySingle();

			for (int i = 2; i <= 1024; i *= 2) {
				CodeTimer.Execute(
					String.Format("Normal Concat ({0})", i),
					10000,
					() => NormalConcat(i)
				);

				CodeTimer.Execute(
					String.Format("StringBuilder ({0})", i),
					10000,
					() => StringBuilder(i)
				);
			}

			Console.WriteLine("Press any key to continue...");
			Console.ReadKey();
		}

		private static readonly string STR = "0123456789";

		private static string NormalConcat(int count) {
			var result = "";
			for (int i = 0; i < count; i++) result += STR;
			return result;
		}

		private static string StringBuilder(int count) {
			var builder = new StringBuilder();
			for (int i = 0; i < count; i++) builder.Append(STR);
			return builder.ToString();
		}
	}
}
